home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 11 / Mac Magazin and MacEasy Magazine CD - Issue 11.iso / Sharewarebibliothek / Entwickler / WASTE 1.1b1 Distribution / Demo Source / WEDemoSounds.p < prev    next >
Text File  |  1995-06-01  |  2KB  |  83 lines

  1. unit WEDemoSounds;
  2.  
  3. { WASTE DEMO PROJECT: }
  4. { Object Handlers for embedded sounds }
  5.  
  6. { Copyright © 1993-1995 Marco Piovanelli }
  7. { All Rights Reserved }
  8.  
  9. { Based on code written by by Michael F. Kamprath, kamprath@earthlink.net }
  10.  
  11. interface
  12.     uses
  13.         WEDemoIntf;
  14.  
  15.     function HandleNewSound (var defaultObjectSize: Point;
  16.                                     objectRef: WEObjectReference): OSErr;
  17.     function HandleDrawSound (destRect: Rect;
  18.                                     objectRef: WEObjectReference): OSErr;
  19.     function HandleClickSound (hitPt: Point;
  20.                                     modifiers: Integer;
  21.                                     clickTime: LongInt;
  22.                                     objectRef: WEObjectReference): Boolean;
  23.  
  24. implementation
  25.     uses
  26.         Icons, Sound;
  27.  
  28.     const
  29.  
  30.         kSoundIconID = 550;        { resource ID of sound icon family resources }
  31.  
  32.     function HandleNewSound (var defaultObjectSize: Point;
  33.                                     objectRef: WEObjectReference): OSErr;
  34.     begin
  35.  
  36. { we'll use a standard 32x32 icon to represent the sound object }
  37.         defaultObjectSize.v := 32;
  38.         defaultObjectSize.h := 32;
  39.  
  40. { return error code }
  41.         HandleNewSound := noErr;
  42.  
  43.     end;  { HandleNewSound }
  44.  
  45.     function HandleDrawSound (destRect: Rect;
  46.                                     objectRef: WEObjectReference): OSErr;
  47.     begin
  48.  
  49. { draw the sound icon }
  50.         HandleDrawSound := PlotIconID(destRect, atBottom, ttNone, kSoundIconID);
  51.  
  52.     end;  { HandleDrawSound }
  53.  
  54.     function HandleClickSound (hitPt: Point;
  55.                                     modifiers: Integer;
  56.                                     clickTime: LongInt;
  57.                                     objectRef: WEObjectReference): Boolean;
  58.         var
  59.             theSound: SndListHandle;
  60.     begin
  61.  
  62. { WASTE sets the low bit of modifiers on double (multiple) clicks }
  63.         if (BAND(modifiers, $0001) <> 0) then
  64.             begin
  65.  
  66. { get a handle to the object data (in this case, a 'snd ' handle) }
  67.                 theSound := SndListHandle(WEGetObjectDataHandle(objectRef));
  68.  
  69. { play the sound }
  70.                 if (SndPlay(nil, theSound, false) <> noErr) then
  71.                     ;
  72.  
  73. { return TRUE so WASTE knows we handled the click }
  74.                 HandleClickSound := true;
  75.             end
  76.         else
  77.  
  78. { not a double click: let WASTE handle the mouse-down }
  79.             HandleClickSound := false;
  80.  
  81.     end;  { HandleClickSound }
  82.  
  83. end.